home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-12-20 | 3.3 KB | 89 lines | [TEXT/CWIE] |
- ///////////////////////////////////////////////////////////////////////////////
- //
- // CBaseEventServer.h
- //
- // This is a mix-in class that provides your control with basic
- // message sending capabilities.
- //
- // To Use this class:
- // 1. Your control should (multiply) inherit from CBaseEventServer.
- // 2. Call AddOutGoingInterface in the constructor of your control.
- // This sets up a connection point for (each) outgoing interface that
- // you want your EventServer to support. Right now, it only supports
- // a single interface -- if you call AddOutGoingInterface more than once,
- // you'll fail an assertion. AddOutGoingInterface must be called before
- // SetUpConnectionPoints (read on...).
- // 3. Call SetUpConnectionPoints in your constructor, after calling
- // AddOutGoingInterface.
- // 4. Override QueryInterface, and sure to call
- // CBaseEventServer::QueryInterface from within your override. Do not
- // depend on CBaseEventServer::QueryInterface calling
- // CBaseCOM::QueryInterface, even though it inherits from CBaseCOM. Call
- // CBaseControl::QueryInterface inside your override instead.
- // 5. You do NOT need to override FireEvent, as you normally would to
- // fire events -- you get this now as part of CBaseEventServer.
- // Remove your override if you're retrofitting a control that already
- // sends events. Of course, you still need to override FireOneEvent
- // for the event(s) you're sending.
- //
-
- #ifndef __CBaseEventServer__
- #define __CBaseEventServer__
-
- #include "BDInterfaces.h"
- #include "CBaseCOM.h"
-
- class CCPContainer;
- class IConnectionPointContainer;
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // constants
- //
-
- // we currently only support one connection at a time
- const short NUM_EVENT_SERVER_CONNECTIONS = 1;
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // class declaration
- //
-
- class CBaseEventServer : public CBaseCOM
- {
- public:
-
- // Initialization
- CBaseEventServer(void);
- ~CBaseEventServer();
-
- // *** IUnknown methods ***
- STDMETHOD (QueryInterface)(REFIID inRefID, void** outObj);
- STDMETHOD_ (Uint32, AddRef)(void) { return CBaseCOM::AddRef(); }
- STDMETHOD_ (Uint32, Release)(void) { return CBaseCOM::Release(); }
-
- protected:
- virtual Boolean AddOutGoingInterface(IID outgoingInterfaceID);
- virtual void SetUpConnectionPoints(void);
-
- // These methods are usually rewritten for each of the other samples.
- STDMETHOD (FireEvent) (REFIID refID, long eventID, PlatformEvent * event);
- STDMETHOD (FireOneEvent)(REFIID refID, long eventID, IUnknown * eventTarget, EventRecord * event) PURE;
-
- protected:
- IID mOutgoingInterfaceID; // eventually we need a list of these...
- CCPContainer * mCPContainerObj;
-
- // This member is a duplicate of the one in CBaseControl, which is used
- // in CBaseControl's QueryInterface. It's here in CBaseEventServer because
- // we need the same instance variable, but we don't want CBaseEventServer
- // to inherit from CBaseControl to get it. Ideally, we should MOVE it
- // out of CBaseControl into CBaseEventServer, but that would require a
- // retrofit of all controls that already send events without inheriting from
- // CBaseEventServer. Right now we're duplicating the QueryInterface in this
- // mix-in to avoid requiring a retrofit.
- IConnectionPointContainer * mCPContainerP;
- };
-
- #endif // __CBaseEventServer__
-